//
//  MainViewController.m
//  GuMoonNews
//
//  Created by 胡发冬 on 16/8/2.
//  Copyright © 2016年 胡发冬. All rights reserved.
//

#import "MainViewController.h"
#import "BrowserViewController.h"

#import "Soap.h"
#import "XMLReader.h"


@interface MainViewController ()
{
    
    UIViewController *startViewController;
    
}

@end

@implementation MainViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    //self.view.backgroundColor = [UIColor lightGrayColor];
    
    NSArray *imageList = @[[UIImage imageNamed:@"user1234.png"], [UIImage imageNamed:@"collection.png"], [UIImage imageNamed:@"wechat.png"], [UIImage imageNamed:@"close.png"]];
    sideBar = [[CDSideBarController alloc] initWithImages:imageList];
    sideBar.delegate = self;
    
    //将storyBoard实例化，“Main”为StoryBoard的名称
    //UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    //将控制器实例化
    //UIStoryboard *myStoryBoard = [UIStoryboard storyboardWithName:@"My" bundle:nil];
    startViewController =[self.storyboard instantiateViewControllerWithIdentifier:@"StartViewController"];
    
    
}
-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    
    [sideBar insertMenuButtonOnView:[UIApplication sharedApplication].delegate.window atPosition:CGPointMake(self.view.frame.size.width - 60, 40)];
    
    
    
    
    
}
- (void)menuButtonClicked:(int)index
{
    
    switch (index) {
        case 0:
            
            break;
            
        case 1:
            
            break;
            
        case 2:
            
            break;
            
        case 3:
            [self Logout];
            break;
            
        default:
            break;
    }
    
    
}

- (IBAction)allTheWeb:(UIButton *)sender {
    
    
    
    
    
    NSDictionary *dic=[NSDictionary dictionaryWithObjectsAndKeys:@"1",@"2",@"3",@"4",@"5",@"6", nil];


    NSLog(@"%@",dic);


    
}

-(void)BrowserUrl:(NSString *)url{
    
    BrowserViewController *browserViewController = [[BrowserViewController alloc]initWithNibName:@"BrowserViewController" bundle:[NSBundle mainBundle]];

    browserViewController.weburl = url;
    
    [self presentViewController:browserViewController animated:YES completion:nil];
    
    
    
    
    
    
    
}
- (void)Logout{
    
    
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    [userDefaults setObject:@"0" forKey:@"loginStatus"];
    [userDefaults synchronize];
    
    NSLog(@"loginStatus=%@",[userDefaults objectForKey:@"loginStatus"]);

    
    CATransition *animation = [CATransition animation];
    animation.duration = 0.8;
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
    animation.type = @"rippleEffect";
   
    
    [self.view.window.layer addAnimation:animation forKey:nil];
    [self presentViewController:startViewController animated:YES completion:nil];
    
    
}


@end
